<?php

namespace App\Api\V1\Controllers\Boilerplate;

use App\Api\V1\Services\Boilerplate\UserService;
use Tymon\JWTAuth\JWTAuth;
use App\Http\Controllers\Controller;
use App\Api\V1\Requests\Boilerplate\LoginRequest;

class LoginController extends Controller
{
    /**
     * @apiVersion v1.0.0
     * @api        {post} /api/auth/login  用户登录 POST
     * @apiName    login
     * @apiGroup   auth
     * @apiDescription  {pos}广告位置，参数说明 =》 1：首页轮播图 2：反馈顶部轮播图 3：会员日顶部轮播图 4：应聘顶部轮播图
     * @apiSuccessExample {JSON} 结果描述
     * {
     *      "code": 0,
     *      "status_code": 200,
     *      "message": "请求成功!",
     *      "data": [
     *          {
     *              "id": 7, // 广告id
     *              "pos": "4", // 广告位置
     *              "img_url": "https://lorempixel.com/640/480/?55999", // 广告图片
     *              "title": "Ms.",// 标题
     *              "link_url": "", // 图片链接
     *              "sort_order": "1" // 排序
     *          }
     *      ]
     * }
     *
     */
    /**
     * @param LoginRequest $request
     * @param JWTAuth $JWTAuth
     * @return \Illuminate\Http\JsonResponse
     */
    public function login(LoginRequest $request, UserService $userService)
    {
        $credentials = $request->only(['username', 'password']);
        $res = $userService->doLogin($credentials);
        return $this->success($res);
    }
}
